package com.vpen.config;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.vpen.utils.CertificateHolder;
import com.vpen.utils.GenerateUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author Vpen
 * @date 2024/11/25 9:56
 */
@Component
public class CertificateBean {



    @Bean
    public CertificateHolder certBean(){
        // 先不处理传参了
        LocalDateTime start = LocalDateTimeUtil.now();
        LocalDateTime end = start.plusYears(3);
        // 生成证书
        return GenerateUtil.generateCertificate("CN=NoBody", new Date(DateUtil.date(start).getTime()), new Date(DateUtil.date(end).getTime()));
    }


}



